package com.neu.tly.test;
import java.sql.*;

/**
 * Created by IntelliJ IDEA 2019.
 * User: Yuri
 * Date: 2020/7/15
 * Description锛�
 */
public class test_1 {
    public static void main(String[] args) {
        String drivername = "com.mysql.cj.jdbc.Driver";

        String url = "jdbc:mysql://localhost:3308/test?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2B8";
        String user = "root";
        String password = "tly123123";

        Connection connection = null;
        Statement statement = null;
        ResultSet resultSet = null;
        PreparedStatement preparedStatement = null;

        try {
            Class.forName(drivername);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }

        try {
            DriverManager.getConnection(url, user, password);
            System.out.println(connection);

            String sql = "create table user" +
                    "(id int auto_increament primary key," +
                    " username varchar(50)," +
                    " password varchar (50))";
            String sql2 = "insert into user value(null, 'Yuri', '12345')";
            String sql3 = "update user set password = '8888' where id = 1";
            String sql4 = "select * from user";

            statement = connection.createStatement();
            //preparedStatement = connection.prepareStatement(sql);

            statement.execute(sql);
            //statement.executeUpdate(sql2);
            //statement.executeUpdate(sql3);
			/*
			 * resultSet = statement.executeQuery(sql4);
			 * 
			 * while (resultSet.next()){ System.out.println(resultSet.getInt(1) + "  " +
			 * resultSet.getString(2) + "  " + resultSet.getString(3)); }
			 * System.out.println(resultSet.toString());
			 */
        } catch (SQLException e) {
            e.printStackTrace();
        }


    }
}

